package com.example.service.impl;

import com.example.dao.StudentDao;
import com.example.dao.TeacherDao;
import com.example.entity.Student;
import com.example.service.StudentService;
import com.example.service.TeacherService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudentServiceImpl implements StudentService {


    @Autowired
    private StudentDao studentDao;



    @Override
    public List<Student> getPage(int currentPage, int pageSize) {
        currentPage=currentPage*pageSize-pageSize;
        return studentDao.getPage(currentPage,pageSize);
    }

    @Override
    public int getTotalCount() {

        return studentDao.getTotalCount();
    }

    @Override
    public Boolean add(Student student) {
        int i = studentDao.add(student);
        if (i>=1){
            return true;
        }
        return false;
    }

    @Override
    public Boolean deleteById(Integer id) {

        return studentDao.deleteById(id);
    }

    @Override
    public Boolean update(Student student) {
        int i = studentDao.update(student);
        if (i>=1){
            return true;
        }
        return false;
    }

    @Override
    public Student getOne(int id) {
        return studentDao.getOne(id);
    }


}
